/**************************************************************
 *@ProjectName: blweibo
 *@FileName: ChoiceActivity.java
 *@Date: 2011-5-31
 *@Copyright: 2011 www.hrbanlv.com Inc. All rights reserved.
 **************************************************************/
package com.zhiweibo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

/**
 * The Class ChoiceActivity.
 * 
 * @author SunHaibin
 * @since Android 1.6
 * @history 2011-5-31
 */
public class ChoiceActivity extends Activity implements View.OnClickListener {

    /** The MOD e_ detai l_ popu p_ window. */
    public static int MODE_DETAIL_POPUP_WINDOW = 1;

    /** The MOD e_ none. */
    public static int MODE_NONE = 255;

    /** The lauch mode. */
    private int lauchMode;

    /** The loaded. */
    private final boolean loaded = false;

    /**
     * Prepare detail window.
     * 
     * @param paramIntent
     *            the param intent
     */
    private void prepareDetailWindow(Intent paramIntent) {
        int k;
        if (paramIntent.getBooleanExtra("EXTRA_IS_SELF", false)) {
            k = View.VISIBLE;
        } else {
            k = View.GONE;
        }
        TextView localTextView = (TextView) findViewById(R.id.tvDelete);
        localTextView.setOnClickListener(this);
        localTextView.setVisibility(k);
        findViewById(R.id.detail_popup_window).setVisibility(View.VISIBLE);
        findViewById(R.id.vBelowDelete).setVisibility(k);
        findViewById(R.id.tvDestroy).setOnClickListener(this);
        findViewById(R.id.tvShare).setOnClickListener(this);
    }

    /*
     * (non-Javadoc)
     * 
     * @see android.view.View.OnClickListener#onClick(android.view.View)
     */
    @Override
    public void onClick(View paramView) {
        int i = -1;
        String str = "EXTRA_RESULT_SELECTED";
        switch (paramView.getId()) {
        case R.id.tvShare:
            setResult(i, new Intent().putExtra(str, 1));
            finish();
            break;
        case R.id.tvDelete:
            setResult(i, new Intent().putExtra(str, 2));
            finish();
            break;
        case R.id.tvDestroy:
            finish();
            break;
        case R.id.tvReport:
            setResult(i, new Intent().putExtra(str, 4));
            finish();
            break;
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.choice_layout);
        Intent localIntent = getIntent();
        lauchMode = localIntent.getIntExtra("com.hbr.ChoiceActivity.EXTRA_LAUCH_MODE", -1);
        if (lauchMode == 1) {
            prepareDetailWindow(localIntent);
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see android.app.Activity#onTouchEvent(android.view.MotionEvent)
     */
    @Override
    public boolean onTouchEvent(MotionEvent paramMotionEvent) {
        finish();
        return super.onTouchEvent(paramMotionEvent);
    }

    /*
     * (non-Javadoc)
     * 
     * @see android.app.Activity#onWindowFocusChanged(boolean)
     */
    @Override
    public void onWindowFocusChanged(boolean paramBoolean) {
        super.onWindowFocusChanged(paramBoolean);
        if ((!loaded) && (paramBoolean)) {
            switch (lauchMode) {
            case 1:
                View localView = findViewById(R.id.detail_popup_window);
                Animation localAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_bottom_to_top);
                localView.startAnimation(localAnimation);
                break;
            }
        }
    }
}